﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ServicePremiseFrame.ascx.cs"
    Inherits="AB.ServiceDirectory.Design.WebUserControls.Frame.ServicePremiseFrame" %>
<%@ Register TagPrefix="wuc" TagName="AssociatePremiseFrame" Src="~/WebUserControls/Lookup/AssociatePremiseLookup.ascx" %>
<script type="text/javascript">
    function confirmRemove() {
        return confirm('Do you want to delete this premise which associated with the service ?');
    }
</script>

        <asp:GridView ID="GridViewServicePremises" CssClass="tablesorter table-top-line"
            runat="server" DataSourceID="ObjectDataSourcePremiseFrame" AutoGenerateColumns="False"
            AllowPaging="True" PageSize="10" AllowSorting="True" DataKeyNames="ServiceId,PremiseId">
            <Columns>
                <asp:TemplateField HeaderText="Location Name" SortExpression="LocationName">
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# string.Format("~/Premises/PremiseDetails.aspx?id={0}", Eval("PremiseId")) %>'
                            Text='<%# Eval("Premise.LocationName") %>'>
                        </asp:HyperLink>
                    </ItemTemplate>
                    <HeaderStyle CssClass="header" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Address" SortExpression="Address">
                    <ItemTemplate>
                        <%# Eval("Premise.Address.AddressLine") %>
                    </ItemTemplate>
                    <HeaderStyle CssClass="header" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Phone Number" SortExpression="PhoneNumber">
                    <ItemTemplate>
                        <%# Eval("Premise.PhoneNumber") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Project Code" SortExpression="ProjectCode">
                    <ItemTemplate>
                        <%# Eval("ProjectCode") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButtonRemove" OnClientClick="return confirmRemove()" CommandName="delete"
                            CausesValidation="False" runat="server">Remove</asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerStyle CssClass="pagination_table" />
            <EmptyDataTemplate>
                There are no items to show.
            </EmptyDataTemplate>
        </asp:GridView>
        <asp:ObjectDataSource ID="ObjectDataSourcePremiseFrame" runat="server" SelectMethod="GetServicePremise"
            TypeName="AB.ServiceDirectory.BO.ServicePremiseBO" OnSelecting="ObjectDataSourceTeam_Selecting"
            EnablePaging="true" SelectCountMethod="GetServicePremiseCount" StartRowIndexParameterName="startRowIndex"
            MaximumRowsParameterName="maxRows" SortParameterName="sortType" DeleteMethod="RemoveAssociatedServicePremise">
            <SelectParameters>
                <asp:Parameter Name="filter" Type="Object" ConvertEmptyStringToNull="false" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="serviceId" Type="Int32" />
                <asp:Parameter Name="premiseId" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <br />
        <asp:Button ID="ButtonAssociatePremise" runat="server" Text="Associate new premise"
            CssClass="st-button right" OnClick="ButtonAssociatePremise_Click" />
        <wuc:AssociatePremiseFrame ID="AssociatePremiseFrame" runat="server" />
        <div class="clear">
        </div>

